package Nowcoder;

public class nc {
    public static void main(String[] args) {
        int [] arr ={7,1,8,9,0};
        int a = 3;
        int b = 3;

        int res = 0;
        for(int i = 0;i<arr.length-2;i++){
            for(int j = i+1;j<arr.length-1;j++){
                if(Math.abs(arr[i]-arr[j])<=a){
                    for(int k = j+1;k<arr.length;k++){
                        if(arr[j]-arr[k]<=b){
                            res++;
                        }
                    }
                }
            }
        }
        System.out.println(res);
    }
}
